<template>
  <transition name="v-loading-fade" @after-leave="handleAfterLeave">
    <div
      v-show="visible"
      class="v-loading-mask"
      :class="[className, { 'is-fullscreen': fullscreen }]">
      <div class="v-loading-spinner">
        <v-spinner :size="38" name="spin" color="#1B97FF" />
        <p v-if="text" class="v-loading-text">{{ text }}</p>
      </div>
    </div>
  </transition>
</template>

<script>
  import VSpiner from '@/vuego/components/v-spinner/v-spinner';

  export default {
    name: 'VLoading',
    data() {
      return {
        text: null,
        fullscreen: true,
        visible: false,
        className: '',
      };
    },
    methods: {
      handleAfterLeave() {
        this.$emit('after-leave');
      },
      setText(text) {
        this.text = text;
      },
    },
    components: {
      VSpiner,
    },
  };
</script>
